import type { AutoInspectionItemModel } from './models';

import { requestClient } from '#/api/request';

/**
 * 查询自动点检项数据集合
 * @param planId 点检计划 Id
 * @returns 返回查询结果
 */
export async function getAutoInspectionItemListApi(planId: number) {
  return requestClient.get<AutoInspectionItemModel[]>(
    '/mes/equipment/inspection/item/auto/list',
    {
      params: { planId },
    },
  );
}

/**
 * 分页查询自动点检项数据集合
 * @param params 分页查询参数
 * @returns 返回查询结果
 */
export async function getAutoInspectionItemPagedListApi(params?: PageParams) {
  return requestClient.get<PaginationResult<AutoInspectionItemModel>>(
    '/mes/equipment/inspection/item/auto/list-page',
    {
      params,
    },
  );
}

/**
 * 创建自动点检项
 * @param data 要创建的自动点检项
 * @returns 返回结果
 */
export async function createAutoInspectionItemApi(data: any) {
  return requestClient.post<boolean>(
    '/mes/equipment/inspection/item/auto',
    data,
  );
}

/**
 * 更新自动点检项
 * @param id 自动点检项 Id
 * @param data 要更新的自动点检项
 * @returns 返回结果
 */
export async function updateAutoInspectionItemApi(id: number, data: any) {
  return requestClient.put<boolean>(
    `/mes/equipment/inspection/item/auto/${id}`,
    data,
  );
}

/**
 * 删除自动点检项
 * @param id 自动点检项 Id
 * @returns 返回结果
 */
export async function deleteAutoInspectionItemApi(id: number) {
  return requestClient.delete<boolean>(
    `/mes/equipment/inspection/item/auto/${id}`,
  );
}
